package main

import "fmt"

func longestConsecutive(nums []int) int {
	mp := make(map[int]bool)
	for _, num := range nums {
		mp[num] = true
	}
	res := 0
	for i := range mp {
		if mp[i-1] == false {
			length := 1
			for mp[i+1] == true {
				i++
				length++
			}
			if length > res {
				res = length
			}
		}
	}
	return res
}

func main() {
	nums := []int{0, 3, 7, 2, 5, 8, 4, 6, 0, 1}
	res := longestConsecutive(nums)
	fmt.Println(res)
}
